/********************************************************************
	created:	2008/09/08
	author:		Gary
	purpose:	
	email:		renjiahui@gmail.com
	site:		http://code.google.com/p/smsservice/
*********************************************************************/
// UDPClient.h: interface for the CTCPClient class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_UDPCLIENT_H__7BC75DAD_6259_4B87_9D2B_8A5726303B2C__INCLUDED_)
#define AFX_UDPCLIENT_H__7BC75DAD_6259_4B87_9D2B_8A5726303B2C__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <stdio.h>
#include <winsock2.h>
#include <mswsock.h>
#include "ISocket.h"

class CUDPClient : public ISocket
{
public:
	CUDPClient();
	virtual ~CUDPClient();
public:
    DWORD  Write(LPCTSTR ReadBuffer, DWORD size, LPCTSTR pAddr, unsigned short wPort);
    DWORD  Write(LPCTSTR ReadBuffer, DWORD size, SOCKADDR_IN remote_addr);
public:
	virtual VOID OnConnect();
	virtual VOID OnConnectFailed();
	virtual DWORD OnRead(LPCTSTR ReadBuffer, DWORD size, SOCKADDR_IN addr);
	virtual VOID OnConnectionBroken();
	virtual ISocket* OnAccept(SOCKET socket, SOCKADDR_IN* RemoteAddr, DWORD len);
public:
    BOOL CloseSocket();	
    int  CloseSocketSafe(SOCKET socket);
    BOOL CreateServer(USHORT Port);	
	BOOL SetOptLinger(SOCKET socket);
public:
    LOG4CPLUS_CLASS_DECLARE( _s_logger );

};

#endif // !defined(AFX_UDPCLIENT_H__7BC75DAD_6259_4B87_9D2B_8A5726303B2C__INCLUDED_)
